<?php 
/*
Plugin Name: MyMail - Email Newsletter Plugin for WordPress
Plugin URI: http://revaxarts-themes.com/?t=mymail
Description: advanced Newsletter Plugin for WordPress. Create, Send and Track your Newsletter Campaigns
Version: 1.3.6.1
Author: revaxarts.com
Author URI: http://revaxarts.com
*/

define('MYMAIL_VERSION', '1.3.6.1');
define('MYMAIL_DIR', WP_PLUGIN_DIR.'/myMail');
define('MYMAIL_URI', plugins_url().'/myMail');
define('MYMAIL_SLUG', substr(__FILE__,strlen(WP_PLUGIN_DIR)+1)); // "myMail/myMail.php"

require_once 'includes/functions.php';
require_once 'classes/settings.class.php';
require_once 'classes/mymail.class.php';
require_once 'classes/subscriber.class.php';
require_once 'classes/manage.class.php';
require_once 'classes/templates.class.php';
require_once 'classes/widget.class.php';
require_once 'classes/autoresponder.class.php';

global $mymail_options, $mymail, $mymail_subscriber, $mymail_templates, $mymail_settings, $mymail_manage, $mymail_autoresponder, $mymail_notices;

$mymail_options = get_option( 'mymail_options' );

$mymail = new mymail();

$mymail_subscriber = new mymail_subscriber();

$mymail_templates = new mymail_templates();

$mymail_autoresponder = new mymail_autoresponder();

$mymail_manage = new mymail_manage();

$mymail_settings = new mymail_settings();

add_action( 'widgets_init', create_function( '', 'register_widget( "mymail_signup" );register_widget( "mymail_list_newsletter" );' ) );

if(mymail_option('system_mail')){

	if(function_exists('wp_mail')){
		mymail_notice('function <strong>wp_mail</strong> already exists from a different plugin! Please disable it before using MyMails wp_mail alternative!', 'error', true);
				
	}else{
		
		function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
			$message = strip_tags( str_replace(array('<br>', '<br />'), "\n", $message));
			return mymail_wp_mail( $to, $subject, nl2br($message), $headers, $attachments );
		}
		
		
		function mymail_password_reset_link_fix($message, $key){
			$str = network_site_url("wp-login.php?action=rp&key=$key");
			
			return str_replace('<'.$str, $str, $message);
			
		}
		
		add_filter('retrieve_password_message', 'mymail_password_reset_link_fix', 10, 2);

	}
}


//Update Class
require_once 'classes/update.class.php';
new Envato_Plugin_Update(mymail_option('purchasecode'), array(
	'remote_url' => "http://update.revaxarts-themes.com",
	'version' => MYMAIL_VERSION,
	'plugin_slug' => MYMAIL_SLUG,
));
?>